package com.googlecode.flealancemarket.tapestry.pages.inbox;

import com.googlecode.flealancemarket.core.tapestry.SpringBean;
import com.googlecode.flealancemarket.metamodel.PrivateMessage;
import com.googlecode.flealancemarket.service.commands.CountSentMessagesForUser;
import com.googlecode.flealancemarket.service.commands.GetSentMessagesForUser;
import java.util.List;
import org.apache.tapestry.ioc.annotations.Inject;

/**
 *
 * @author vanja
 */
public class Sent extends AbstractMessagesPage {

    @Inject
    @SpringBean("CountSentMessagesForUser")
    private CountSentMessagesForUser countSentMessagesForUser;

    @Inject
    @SpringBean("GetSentMessagesForUser")
    private GetSentMessagesForUser getSentMessagesForUser;

    @Override
    public int calculateMessagesNumber() {
        countSentMessagesForUser.setUser(getUser());
        return countSentMessagesForUser.execute();
    }

    @Override
    public List<PrivateMessage> receiveMessagesList() {
        getSentMessagesForUser.setPage(getPageNumber());
        getSentMessagesForUser.setUser(getUser());
        return getSentMessagesForUser.execute();
    }



}
